﻿var myDate = new Date();
var year = myDate.getFullYear();
var month = myDate.getMonth()+1;
var day = myDate.getDate();
function start() {
	if(cm.getChannelNumber()!=1){
		cm.dispose();
		return;
	}
	var time = (year+""+month+""+day)*1;
	var em = cm.getEventManager("Zodiac");
	if (em==null){
		cm.worldSpouseMessage(0x15, "[生肖系统]： 开奖结果记录失败！");
		cm.worldSpouseMessage(0x15, "[生肖系统]： 开奖结果记录失败！");
		cm.worldSpouseMessage(0x15, "[生肖系统]： 开奖结果记录失败！");
		cm.dispose();
		return;
	}
	var CC = em.getProperty("Zodiac");
	if(em.getProperty("AAA")=="1"){
		cm.dispose();
		return;
	}
	em.broadcastServerMsg(5120117, "[12生肖竞猜] 本次竞猜结果为【"+CC+"】请中奖朋友在8~10期间领取！",true);
	cm.worldSpouseMessage(0x15, "[12生肖竞猜]： 本次竞猜结果为【"+CC+"】。开奖后请中奖玩家在8~10点内领取奖励，逾期无效！");
	cm.worldSpouseMessage(0x15, "[12生肖竞猜]： 本次竞猜结果为【"+CC+"】。开奖后请中奖玩家在8~10点内领取奖励，逾期无效！");
	cm.worldSpouseMessage(0x15, "[12生肖竞猜]： 本次竞猜结果为【"+CC+"】。开奖后请中奖玩家在8~10点内领取奖励，逾期无效！");
	var db = cm.getConnection();
	var sql = "insert into savezodiac values(0,'"+CC+"',"+time+")";
	var pstmt = db.prepareStatement(sql);
	pstmt.executeUpdate();
	pstmt.close();
	cm.worldSpouseMessage(0x15, "[生肖系统]： 开奖结果记录成功！");
	em.setProperty("AAA","1");
	cm.dispose();
}